package com.imooc.imoocbilibili.controller;

import java.util.Arrays;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import com.imooc.imoocbilibili.entity.VideoCoin;
import com.imooc.imoocbilibili.service.VideoCoinService;
import com.imooc.imoocbilibili.utils.R;


/**
 * 视频硬币表
 *
 * @author jl
 * @since 2022-04-10 21:13:43
 */
@RestController
@RequestMapping("imoocbilibili/videocoin")
@RequiredArgsConstructor
public class VideoCoinController {

    private final VideoCoinService videoCoinService;

    /**
     * 分页查询视频硬币表
     */
    @GetMapping("/list")
    public R list(@RequestParam("pageNo") Integer pageNo, @RequestParam("pageSize") Integer pageSize) {
        return R.ok(videoCoinService.queryPage(pageNo, pageSize));
    }


    /**
     * 根据主键查询视频硬币表
     */
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id") Long id) {
        VideoCoin videoCoin =videoCoinService.getById(id);
        return R.ok(videoCoin);
    }

    /**
     * 新增视频硬币表
     */
    @PostMapping("/save")
    public R save(@RequestBody VideoCoin videoCoin) {
            videoCoinService.save(videoCoin);
        return R.ok();
    }

    /**
     * 修改视频硬币表
     */
    @PutMapping("/update")
    public R update(@RequestBody VideoCoin videoCoin) {
            videoCoinService.updateById(videoCoin);
        return R.ok();
    }

    /**
     * 删除视频硬币表
     */
    @DeleteMapping("/delete")
    public R delete(@RequestBody Long[] ids) {
            videoCoinService.removeByIds(Arrays.asList(ids));
        return R.ok();
    }

}
